home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / tehkanwc.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  27KB  |  804 lines

  1. /***************************************************************************
  2.  
  3. Tehkan World Cup - (c) Tehkan 1985
  4.  
  5.  
  6. Ernesto Corvi
  7. ernesto@imagina.com
  8.  
  9. Roberto Juan Fresca
  10. robbiex@rocketmail.com
  11.  
  12. TODO:
  13. - dip switches and input ports for Gridiron and Tee'd Off
  14.  
  15. NOTES:
  16. - Samples MUST be on Memory Region 4
  17.  
  18. ***************************************************************************/
  19.  
  20. #include "driver.h"
  21. #include "vidhrdw/generic.h"
  22. #include "cpu/z80/z80.h"
  23.  
  24.  
  25. extern unsigned char *tehkanwc_videoram1;
  26. extern size_t tehkanwc_videoram1_size;
  27.  
  28. /* from vidhrdw */
  29. int tehkanwc_vh_start(void);
  30. void tehkanwc_vh_stop(void);
  31. void tehkanwc_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  32. READ_HANDLER( tehkanwc_videoram1_r );
  33. WRITE_HANDLER( tehkanwc_videoram1_w );
  34. READ_HANDLER( tehkanwc_scroll_x_r );
  35. READ_HANDLER( tehkanwc_scroll_y_r );
  36. WRITE_HANDLER( tehkanwc_scroll_x_w );
  37. WRITE_HANDLER( tehkanwc_scroll_y_w );
  38. WRITE_HANDLER( gridiron_led0_w );
  39. WRITE_HANDLER( gridiron_led1_w );
  40.  
  41.  
  42. static unsigned char *shared_ram;
  43.  
  44. static READ_HANDLER( shared_r )
  45. {
  46.     return shared_ram[offset];
  47. }
  48.  
  49. static WRITE_HANDLER( shared_w )
  50. {
  51.     shared_ram[offset] = data;
  52. }
  53.  
  54.  
  55. static WRITE_HANDLER( sub_cpu_halt_w )
  56. {
  57.     if (data)
  58.         cpu_set_reset_line(1,CLEAR_LINE);
  59.     else
  60.         cpu_set_reset_line(1,ASSERT_LINE);
  61. }
  62.  
  63.  
  64.  
  65. static int track0[2],track1[2];
  66.  
  67. static READ_HANDLER( tehkanwc_track_0_r )
  68. {
  69.     int joy;
  70.  
  71.     joy = readinputport(10) >> (2*offset);
  72.     if (joy & 1) return -63;
  73.     if (joy & 2) return 63;
  74.     return readinputport(3 + offset) - track0[offset];
  75. }
  76.  
  77. static READ_HANDLER( tehkanwc_track_1_r )
  78. {
  79.     int joy;
  80.  
  81.     joy = readinputport(10) >> (4+2*offset);
  82.     if (joy & 1) return -63;
  83.     if (joy & 2) return 63;
  84.     return readinputport(6 + offset) - track1[offset];
  85. }
  86.  
  87. static WRITE_HANDLER( tehkanwc_track_0_reset_w )
  88. {
  89.     /* reset the trackball counters */
  90.     track0[offset] = readinputport(3 + offset) + data;
  91. }
  92.  
  93. static WRITE_HANDLER( tehkanwc_track_1_reset_w )
  94. {
  95.     /* reset the trackball counters */
  96.     track1[offset] = readinputport(6 + offset) + data;
  97. }
  98.  
  99.  
  100.  
  101. static WRITE_HANDLER( sound_command_w )
  102. {
  103.     soundlatch_w(offset,data);
  104.     cpu_cause_interrupt(2,Z80_NMI_INT);
  105. }
  106.  
  107. static void reset_callback(int param)
  108. {
  109.     cpu_set_reset_line(2,PULSE_LINE);
  110. }
  111.  
  112. static WRITE_HANDLER( sound_answer_w )
  113. {
  114.     soundlatch2_w(0,data);
  115.  
  116.     /* in Gridiron, the sound CPU goes in a tight loop after the self test, */
  117.     /* probably waiting to be reset by a watchdog */
  118.     if (cpu_get_pc() == 0x08bc) timer_set(TIME_IN_SEC(1),0,reset_callback);
  119. }
  120.  
  121.  
  122. /* Emulate MSM sound samples with counters */
  123.  
  124. static int msm_data_offs;
  125.  
  126. static READ_HANDLER( tehkanwc_portA_r )
  127. {
  128.     return msm_data_offs & 0xff;
  129. }
  130.  
  131. static READ_HANDLER( tehkanwc_portB_r )
  132. {
  133.     return (msm_data_offs >> 8) & 0xff;
  134. }
  135.  
  136. static WRITE_HANDLER( tehkanwc_portA_w )
  137. {
  138.     msm_data_offs = (msm_data_offs & 0xff00) | data;
  139. }
  140.  
  141. static WRITE_HANDLER( tehkanwc_portB_w )
  142. {
  143.     msm_data_offs = (msm_data_offs & 0x00ff) | (data << 8);
  144. }
  145.  
  146. static WRITE_HANDLER( msm_reset_w )
  147. {
  148.     MSM5205_reset_w(0,data ? 0 : 1);
  149. }
  150.  
  151. void tehkanwc_adpcm_int (int data)
  152. {
  153.     static int toggle;
  154.  
  155.     unsigned char *SAMPLES = memory_region(REGION_SOUND1);
  156.     int msm_data = SAMPLES[msm_data_offs & 0x7fff];
  157.  
  158.     if (toggle == 0)
  159.         MSM5205_data_w(0,(msm_data >> 4) & 0x0f);
  160.     else
  161.     {
  162.         MSM5205_data_w(0,msm_data & 0x0f);
  163.         msm_data_offs++;
  164.     }
  165.  
  166.     toggle ^= 1;
  167. }
  168.  
  169. /* End of MSM with counters emulation */
  170.  
  171.  
  172.  
  173. static struct MemoryReadAddress readmem[] =
  174. {
  175.     { 0x0000, 0xbfff, MRA_ROM },
  176.     { 0xc000, 0xc7ff, MRA_RAM },
  177.     { 0xc800, 0xcfff, shared_r },
  178.     { 0xd000, 0xd3ff, videoram_r },
  179.     { 0xd400, 0xd7ff, colorram_r },
  180.     { 0xd800, 0xddff, paletteram_r },
  181.     { 0xde00, 0xdfff, MRA_RAM },    /* unused part of the palette RAM, I think? Gridiron uses it */
  182.     { 0xe000, 0xe7ff, tehkanwc_videoram1_r },
  183.     { 0xe800, 0xebff, spriteram_r }, /* sprites */
  184.     { 0xec00, 0xec01, tehkanwc_scroll_x_r },
  185.     { 0xec02, 0xec02, tehkanwc_scroll_y_r },
  186.     { 0xf800, 0xf801, tehkanwc_track_0_r }, /* track 0 x/y */
  187.     { 0xf802, 0xf802, input_port_9_r }, /* Coin & Start */
  188.     { 0xf803, 0xf803, input_port_5_r }, /* joy0 - button */
  189.     { 0xf810, 0xf811, tehkanwc_track_1_r }, /* track 1 x/y */
  190.     { 0xf813, 0xf813, input_port_8_r }, /* joy1 - button */
  191.     { 0xf820, 0xf820, soundlatch2_r },    /* answer from the sound CPU */
  192.     { 0xf840, 0xf840, input_port_0_r }, /* DSW1 */
  193.     { 0xf850, 0xf850, input_port_1_r },    /* DSW2 */
  194.     { 0xf860, 0xf860, watchdog_reset_r },
  195.     { 0xf870, 0xf870, input_port_2_r }, /* DSW3 */
  196.     { -1 }    /* end of table */
  197. };
  198.  
  199. static struct MemoryWriteAddress writemem[] =
  200. {
  201.     { 0x0000, 0xbfff, MWA_ROM },
  202.     { 0xc000, 0xc7ff, MWA_RAM },
  203.     { 0xc800, 0xcfff, shared_w, &shared_ram },
  204.     { 0xd000, 0xd3ff, videoram_w, &videoram, &videoram_size },
  205.     { 0xd400, 0xd7ff, colorram_w, &colorram },
  206.     { 0xd800, 0xddff, paletteram_xxxxBBBBGGGGRRRR_swap_w, &paletteram },
  207.     { 0xde00, 0xdfff, MWA_RAM },    /* unused part of the palette RAM, I think? Gridiron uses it */
  208.     { 0xe000, 0xe7ff, tehkanwc_videoram1_w, &tehkanwc_videoram1, &tehkanwc_videoram1_size },
  209.     { 0xe800, 0xebff, spriteram_w, &spriteram, &spriteram_size }, /* sprites */
  210.     { 0xec00, 0xec01, tehkanwc_scroll_x_w },
  211.     { 0xec02, 0xec02, tehkanwc_scroll_y_w },
  212.     { 0xf800, 0xf801, tehkanwc_track_0_reset_w },
  213.     { 0xf802, 0xf802, gridiron_led0_w },
  214.     { 0xf810, 0xf811, tehkanwc_track_1_reset_w },
  215.     { 0xf812, 0xf812, gridiron_led1_w },
  216.     { 0xf820, 0xf820, sound_command_w },
  217.     { 0xf840, 0xf840, sub_cpu_halt_w },
  218.     { -1 }    /* end of table */
  219. };
  220.  
  221. static struct MemoryReadAddress readmem_sub[] =
  222. {
  223.     { 0x0000, 0x7fff, MRA_ROM },
  224.     { 0x8000, 0xc7ff, MRA_RAM },
  225.     { 0xc800, 0xcfff, shared_r },
  226.     { 0xd000, 0xd3ff, videoram_r },
  227.     { 0xd400, 0xd7ff, colorram_r },
  228.     { 0xd800, 0xddff, paletteram_r },
  229.     { 0xde00, 0xdfff, MRA_RAM },    /* unused part of the palette RAM, I think? Gridiron uses it */
  230.     { 0xe000, 0xe7ff, tehkanwc_videoram1_r },
  231.     { 0xe800, 0xebff, spriteram_r }, /* sprites */
  232.     { 0xec00, 0xec01, tehkanwc_scroll_x_r },
  233.     { 0xec02, 0xec02, tehkanwc_scroll_y_r },
  234.     { 0xf860, 0xf860, watchdog_reset_r },
  235.     { -1 }    /* end of table */
  236. };
  237.  
  238. static struct MemoryWriteAddress writemem_sub[] =
  239. {
  240.     { 0x0000, 0x7fff, MWA_ROM },
  241.     { 0xc000, 0xc7ff, MWA_RAM },
  242.     { 0xc800, 0xcfff, shared_w },
  243.     { 0xd000, 0xd3ff, videoram_w },
  244.     { 0xd400, 0xd7ff, colorram_w },
  245.     { 0xd800, 0xddff, paletteram_xxxxBBBBGGGGRRRR_swap_w, &paletteram },
  246.     { 0xde00, 0xdfff, MWA_RAM },    /* unused part of the palette RAM, I think? Gridiron uses it */
  247.     { 0xe000, 0xe7ff, tehkanwc_videoram1_w },
  248.     { 0xe800, 0xebff, spriteram_w }, /* sprites */
  249.     { 0xec00, 0xec01, tehkanwc_scroll_x_w },
  250.     { 0xec02, 0xec02, tehkanwc_scroll_y_w },
  251.     { -1 }    /* end of table */
  252. };
  253.  
  254. static struct MemoryReadAddress readmem_sound[] =
  255. {
  256.     { 0x0000, 0x3fff, MRA_ROM },
  257.     { 0x4000, 0x47ff, MRA_RAM },
  258.     { 0xc000, 0xc000, soundlatch_r },
  259.     { -1 }    /* end of table */
  260. };
  261.  
  262. static struct MemoryWriteAddress writemem_sound[] =
  263. {
  264.     { 0x0000, 0x3fff, MWA_ROM },
  265.     { 0x4000, 0x47ff, MWA_RAM },
  266.     { 0x8001, 0x8001, msm_reset_w },/* MSM51xx reset */
  267.     { 0x8002, 0x8002, MWA_NOP },    /* ?? written in the IRQ handler */
  268.     { 0x8003, 0x8003, MWA_NOP },    /* ?? written in the NMI handler */
  269.     { 0xc000, 0xc000, sound_answer_w },    /* answer for main CPU */
  270.     { -1 }    /* end of table */
  271. };
  272.  
  273. static struct IOReadPort sound_readport[] =
  274. {
  275.     { 0x00, 0x00, AY8910_read_port_0_r },
  276.     { 0x02, 0x02, AY8910_read_port_1_r },
  277.     { -1 }    /* end of table */
  278. };
  279.  
  280. static struct IOWritePort sound_writeport[] =
  281. {
  282.     { 0x00, 0x00, AY8910_write_port_0_w },
  283.     { 0x01, 0x01, AY8910_control_port_0_w },
  284.     { 0x02, 0x02, AY8910_write_port_1_w },
  285.     { 0x03, 0x03, AY8910_control_port_1_w },
  286.     { -1 }    /* end of table */
  287. };
  288.  
  289.  
  290.  
  291. INPUT_PORTS_START( tehkanwc )
  292.     PORT_START /* DSW1 - Active LOW */
  293.     PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )
  294.     PORT_DIPSETTING (   0x01, DEF_STR( 2C_1C ) )
  295.     PORT_DIPSETTING (   0x07, DEF_STR( 1C_1C ) )
  296.     PORT_DIPSETTING (   0x00, DEF_STR( 2C_3C ) )
  297.     PORT_DIPSETTING (   0x06, DEF_STR( 1C_2C ) )
  298.     PORT_DIPSETTING (   0x05, DEF_STR( 1C_3C ) )
  299.     PORT_DIPSETTING (   0x04, DEF_STR( 1C_4C ) )
  300.     PORT_DIPSETTING (   0x03, DEF_STR( 1C_5C ) )
  301.     PORT_DIPSETTING (   0x02, DEF_STR( 1C_6C ) )
  302.     PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )
  303.     PORT_DIPSETTING (   0x08, DEF_STR( 2C_1C ) )
  304.     PORT_DIPSETTING (   0x38, DEF_STR( 1C_1C ) )
  305.     PORT_DIPSETTING (   0x00, DEF_STR( 2C_3C ) )
  306.     PORT_DIPSETTING (   0x30, DEF_STR( 1C_2C ) )
  307.     PORT_DIPSETTING (   0x28, DEF_STR( 1C_3C ) )
  308.     PORT_DIPSETTING (   0x20, DEF_STR( 1C_4C ) )
  309.     PORT_DIPSETTING (   0x18, DEF_STR( 1C_5C ) )
  310.     PORT_DIPSETTING (   0x10, DEF_STR( 1C_6C ) )
  311.     PORT_DIPNAME( 0x40, 0x40, "Extra Time per Coin" )
  312.     PORT_DIPSETTING (   0x40, "Normal" )
  313.     PORT_DIPSETTING (   0x00, "Double" )
  314.     PORT_DIPNAME( 0x80, 0x80, "1 Player Start" )
  315.     PORT_DIPSETTING (   0x00, "2 Credits" )
  316.     PORT_DIPSETTING (   0x80, "1 Credit" )
  317.  
  318.     PORT_START /* DSW2 - Active LOW */
  319.     PORT_DIPNAME( 0x03, 0x03, "1P Game Time" )
  320.     PORT_DIPSETTING (   0x00, "2:30" )
  321.     PORT_DIPSETTING (   0x01, "2:00" )
  322.     PORT_DIPSETTING (   0x03, "1:30" )
  323.     PORT_DIPSETTING (   0x02, "1:00" )
  324.     PORT_DIPNAME( 0x7c, 0x7c, "2P Game Time" )
  325.     PORT_DIPSETTING (   0x00, "5:00/3:00 Extra" )
  326.     PORT_DIPSETTING (   0x60, "5:00/2:45 Extra" )
  327.     PORT_DIPSETTING (   0x20, "5:00/2:35 Extra" )
  328.     PORT_DIPSETTING (   0x40, "5:00/2:30 Extra" )
  329.     PORT_DIPSETTING (   0x04, "4:00/2:30 Extra" )
  330.     PORT_DIPSETTING (   0x64, "4:00/2:15 Extra" )
  331.     PORT_DIPSETTING (   0x24, "4:00/2:05 Extra" )
  332.     PORT_DIPSETTING (   0x44, "4:00/2:00 Extra" )
  333.     PORT_DIPSETTING (   0x1c, "3:30/2:15 Extra" )
  334.     PORT_DIPSETTING (   0x7c, "3:30/2:00 Extra" )
  335.     PORT_DIPSETTING (   0x3c, "3:30/1:50 Extra" )
  336.     PORT_DIPSETTING (   0x5c, "3:30/1:45 Extra" )
  337.     PORT_DIPSETTING (   0x08, "3:00/2:00 Extra" )
  338.     PORT_DIPSETTING (   0x68, "3:00/1:45 Extra" )
  339.     PORT_DIPSETTING (   0x28, "3:00/1:35 Extra" )
  340.     PORT_DIPSETTING (   0x48, "3:00/1:30 Extra" )
  341.     PORT_DIPSETTING (   0x0c, "2:30/1:45 Extra" )
  342.     PORT_DIPSETTING (   0x6c, "2:30/1:30 Extra" )
  343.     PORT_DIPSETTING (   0x2c, "2:30/1:20 Extra" )
  344.     PORT_DIPSETTING (   0x4c, "2:30/1:15 Extra" )
  345.     PORT_DIPSETTING (   0x10, "2:00/1:30 Extra" )
  346.     PORT_DIPSETTING (   0x70, "2:00/1:15 Extra" )
  347.     PORT_DIPSETTING (   0x30, "2:00/1:05 Extra" )
  348.     PORT_DIPSETTING (   0x50, "2:00/1:00 Extra" )
  349.     PORT_DIPSETTING (   0x14, "1:30/1:15 Extra" )
  350.     PORT_DIPSETTING (   0x74, "1:30/1:00 Extra" )
  351.     PORT_DIPSETTING (   0x34, "1:30/0:50 Extra" )
  352.     PORT_DIPSETTING (   0x54, "1:30/0:45 Extra" )
  353.     PORT_DIPSETTING (   0x18, "1:00/1:00 Extra" )
  354.     PORT_DIPSETTING (   0x78, "1:00/0:45 Extra" )
  355.     PORT_DIPSETTING (   0x38, "1:00/0:35 Extra" )
  356.     PORT_DIPSETTING (   0x58, "1:00/0:30 Extra" )
  357.     PORT_DIPNAME( 0x80, 0x80, "Game Type" )
  358.     PORT_DIPSETTING (   0x80, "Timer In" )
  359.     PORT_DIPSETTING (   0x00, "Credit In" )
  360.  
  361.     PORT_START /* DSW3 - Active LOW */
  362.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
  363.     PORT_DIPSETTING (   0x02, "Easy" )
  364.     PORT_DIPSETTING (   0x03, "Normal" )
  365.     PORT_DIPSETTING (   0x01, "Hard" )
  366.     PORT_DIPSETTING (   0x00, "Very Hard" )
  367.     PORT_DIPNAME( 0x04, 0x04, "Timer Speed" )
  368.     PORT_DIPSETTING (   0x04, "60/60" )
  369.     PORT_DIPSETTING (   0x00, "55/60" )
  370.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
  371.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  372.     PORT_DIPSETTING (   0x08, DEF_STR( On ) )
  373.  
  374.     PORT_START /* IN0 - X AXIS */
  375.     PORT_ANALOGX( 0xff, 0x80, IPT_TRACKBALL_X | IPF_PLAYER1, 100, 0, 0, 0, IP_KEY_NONE, IP_KEY_NONE, IP_JOY_NONE, IP_JOY_NONE )
  376.  
  377.     PORT_START /* IN0 - Y AXIS */
  378.     PORT_ANALOGX( 0xff, 0x80, IPT_TRACKBALL_Y | IPF_PLAYER1, 100, 0, 0, 0, IP_KEY_NONE, IP_KEY_NONE, IP_JOY_NONE, IP_JOY_NONE )
  379.  
  380.     PORT_START /* IN0 - BUTTON */
  381.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  382.  
  383.     PORT_START /* IN1 - X AXIS */
  384.     PORT_ANALOGX( 0xff, 0x80, IPT_TRACKBALL_X | IPF_PLAYER2, 100, 0, 0, 0, IP_KEY_NONE, IP_KEY_NONE, IP_JOY_NONE, IP_JOY_NONE )
  385.  
  386.     PORT_START /* IN1 - Y AXIS */
  387.     PORT_ANALOGX( 0xff, 0x80, IPT_TRACKBALL_Y | IPF_PLAYER2, 100, 0, 0, 0, IP_KEY_NONE, IP_KEY_NONE, IP_JOY_NONE, IP_JOY_NONE )
  388.  
  389.     PORT_START /* IN1 - BUTTON */
  390.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  391.  
  392.     PORT_START /* IN2 - Active LOW */
  393.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  394.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  395.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
  396.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
  397.  
  398.     PORT_START    /* fake port to emulate trackballs with keyboard */
  399.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  400.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  401.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  402.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  403.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  404.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  405.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  406.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  407. INPUT_PORTS_END
  408.  
  409.  
  410. INPUT_PORTS_START( gridiron )
  411.     PORT_START /* DSW1 - Active LOW */
  412.     PORT_DIPNAME( 0x01, 0x01, "1 Player Start" )
  413.     PORT_DIPSETTING (   0x00, "2 Credits" )
  414.     PORT_DIPSETTING (   0x01, "1 Credit" )
  415.     PORT_DIPNAME( 0x02, 0x02, "2 Players Start" )
  416.     PORT_DIPSETTING (   0x02, "2 Credits" )
  417.     PORT_DIPSETTING (   0x00, "1 Credit" )
  418.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
  419.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  420.     PORT_DIPSETTING (   0x04, DEF_STR( On ) )
  421.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  422.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  423.     PORT_DIPSETTING (   0x08, DEF_STR( On ) )
  424.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  425.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  426.     PORT_DIPSETTING (   0x10, DEF_STR( On ) )
  427.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  428.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  429.     PORT_DIPSETTING (   0x20, DEF_STR( On ) )
  430.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
  431.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  432.     PORT_DIPSETTING (   0x40, DEF_STR( On ) )
  433.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
  434.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  435.     PORT_DIPSETTING (   0x80, DEF_STR( On ) )
  436.  
  437.     PORT_START /* DSW2 - Active LOW */
  438.     PORT_DIPNAME( 0x03, 0x03, "1P Game Time" )
  439.     PORT_DIPSETTING (   0x00, "2:30" )
  440.     PORT_DIPSETTING (   0x01, "2:00" )
  441.     PORT_DIPSETTING (   0x03, "1:30" )
  442.     PORT_DIPSETTING (   0x02, "1:00" )
  443.     PORT_DIPNAME( 0x7c, 0x7c, "2P Game Time" )
  444.     PORT_DIPSETTING (   0x60, "5:00/3:00 Extra" )
  445.     PORT_DIPSETTING (   0x00, "5:00/2:45 Extra" )
  446.     PORT_DIPSETTING (   0x20, "5:00/2:35 Extra" )
  447.     PORT_DIPSETTING (   0x40, "5:00/2:30 Extra" )
  448.     PORT_DIPSETTING (   0x64, "4:00/2:30 Extra" )
  449.     PORT_DIPSETTING (   0x04, "4:00/2:15 Extra" )
  450.     PORT_DIPSETTING (   0x24, "4:00/2:05 Extra" )
  451.     PORT_DIPSETTING (   0x44, "4:00/2:00 Extra" )
  452.     PORT_DIPSETTING (   0x68, "3:30/2:15 Extra" )
  453.     PORT_DIPSETTING (   0x08, "3:30/2:00 Extra" )
  454.     PORT_DIPSETTING (   0x28, "3:30/1:50 Extra" )
  455.     PORT_DIPSETTING (   0x48, "3:30/1:45 Extra" )
  456.     PORT_DIPSETTING (   0x6c, "3:00/2:00 Extra" )
  457.     PORT_DIPSETTING (   0x0c, "3:00/1:45 Extra" )
  458.     PORT_DIPSETTING (   0x2c, "3:00/1:35 Extra" )
  459.     PORT_DIPSETTING (   0x4c, "3:00/1:30 Extra" )
  460.     PORT_DIPSETTING (   0x7c, "2:30/1:45 Extra" )
  461.     PORT_DIPSETTING (   0x1c, "2:30/1:30 Extra" )
  462.     PORT_DIPSETTING (   0x3c, "2:30/1:20 Extra" )
  463.     PORT_DIPSETTING (   0x5c, "2:30/1:15 Extra" )
  464.     PORT_DIPSETTING (   0x70, "2:00/1:30 Extra" )
  465.     PORT_DIPSETTING (   0x10, "2:00/1:15 Extra" )
  466.     PORT_DIPSETTING (   0x30, "2:00/1:05 Extra" )
  467.     PORT_DIPSETTING (   0x50, "2:00/1:00 Extra" )
  468.     PORT_DIPSETTING (   0x74, "1:30/1:15 Extra" )
  469.     PORT_DIPSETTING (   0x14, "1:30/1:00 Extra" )
  470.     PORT_DIPSETTING (   0x34, "1:30/0:50 Extra" )
  471.     PORT_DIPSETTING (   0x54, "1:30/0:45 Extra" )
  472.     PORT_DIPSETTING (   0x78, "1:00/1:00 Extra" )
  473.     PORT_DIPSETTING (   0x18, "1:00/0:45 Extra" )
  474.     PORT_DIPSETTING (   0x38, "1:00/0:35 Extra" )
  475.     PORT_DIPSETTING (   0x58, "1:00/0:30 Extra" )
  476.     PORT_DIPNAME( 0x80, 0x80, "Game Type?" )
  477.     PORT_DIPSETTING (   0x80, "Timer In" )
  478.     PORT_DIPSETTING (   0x00, "Credit In" )
  479.  
  480.     PORT_START /* DSW3 - Active LOW */
  481.     PORT_DIPNAME( 0x03, 0x03, "Difficulty?" )
  482.     PORT_DIPSETTING (   0x02, "Easy" )
  483.     PORT_DIPSETTING (   0x03, "Normal" )
  484.     PORT_DIPSETTING (   0x01, "Hard" )
  485.     PORT_DIPSETTING (   0x00, "Very Hard" )
  486.     PORT_DIPNAME( 0x04, 0x04, "Timer Speed?" )
  487.     PORT_DIPSETTING (   0x04, "60/60" )
  488.     PORT_DIPSETTING (   0x00, "55/60" )
  489.     PORT_DIPNAME( 0x08, 0x08, "Demo Sounds?" )
  490.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  491.     PORT_DIPSETTING (   0x08, DEF_STR( On ) )
  492.  
  493.     PORT_START /* IN0 - X AXIS */
  494.     PORT_ANALOG( 0xff, 0x80, IPT_TRACKBALL_X | IPF_PLAYER1, 100, 63, 0, 0 )
  495.  
  496.     PORT_START /* IN0 - Y AXIS */
  497.     PORT_ANALOG( 0xff, 0x80, IPT_TRACKBALL_Y | IPF_PLAYER1, 100, 63, 0, 0 )
  498.  
  499.     PORT_START /* IN0 - BUTTON */
  500.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  501.  
  502.     PORT_START /* IN1 - X AXIS */
  503.     PORT_ANALOG( 0xff, 0x80, IPT_TRACKBALL_X | IPF_PLAYER2, 100, 63, 0, 0 )
  504.  
  505.     PORT_START /* IN1 - Y AXIS */
  506.     PORT_ANALOG( 0xff, 0x80, IPT_TRACKBALL_Y | IPF_PLAYER2, 100, 63, 0, 0 )
  507.  
  508.     PORT_START /* IN1 - BUTTON */
  509.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  510.  
  511.     PORT_START /* IN2 - Active LOW */
  512.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  513.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  514.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
  515.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
  516.  
  517.     PORT_START    /* no fake port here */
  518.     PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
  519. INPUT_PORTS_END
  520.  
  521.  
  522. INPUT_PORTS_START( teedoff )
  523.     PORT_START /* DSW1 - Active LOW */
  524.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
  525.     PORT_DIPSETTING (   0x02, DEF_STR( 2C_1C ) )
  526.     PORT_DIPSETTING (   0x03, DEF_STR( 1C_1C ) )
  527.     PORT_DIPSETTING (   0x01, DEF_STR( 1C_2C ) )
  528.     PORT_DIPSETTING (   0x00, DEF_STR( 1C_3C ) )
  529.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) )
  530.     PORT_DIPSETTING (   0x08, DEF_STR( 2C_1C ) )
  531.     PORT_DIPSETTING (   0x0c, DEF_STR( 1C_1C ) )
  532.     PORT_DIPSETTING (   0x04, DEF_STR( 1C_2C ) )
  533.     PORT_DIPSETTING (   0x00, DEF_STR( 1C_3C ) )
  534.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  535.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  536.     PORT_DIPSETTING (   0x10, DEF_STR( On ) )
  537.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  538.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  539.     PORT_DIPSETTING (   0x20, DEF_STR( On ) )
  540.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
  541.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  542.     PORT_DIPSETTING (   0x40, DEF_STR( On ) )
  543.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
  544.     PORT_DIPSETTING (   0x00, DEF_STR( Off ) )
  545.     PORT_DIPSETTING (   0x80, DEF_STR( On ) )
  546.  
  547.     PORT_START /* DSW2 - Active LOW */
  548.     PORT_DIPNAME( 0xff, 0xff, DEF_STR( Unknown ) )
  549.     PORT_DIPSETTING (   0xff, DEF_STR( Off ) )
  550.     PORT_DIPSETTING (   0x00, DEF_STR( On ) )
  551.  
  552.     PORT_START /* DSW3 - Active LOW */
  553.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Unknown ) )
  554.     PORT_DIPSETTING (   0x0f, DEF_STR( Off ) )
  555.     PORT_DIPSETTING (   0x00, DEF_STR( On ) )
  556.  
  557.     PORT_START /* IN0 - X AXIS */
  558.     PORT_ANALOG( 0xff, 0x80, IPT_TRACKBALL_X | IPF_PLAYER1, 100, 63, 0, 0 )
  559.  
  560.     PORT_START /* IN0 - Y AXIS */
  561.     PORT_ANALOG( 0xff, 0x80, IPT_TRACKBALL_Y | IPF_PLAYER1, 100, 63, 0, 0 )
  562.  
  563.     PORT_START /* IN0 - BUTTON */
  564.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  565.  
  566.     PORT_START /* IN1 - X AXIS */
  567.     PORT_ANALOG( 0xff, 0x80, IPT_TRACKBALL_X | IPF_PLAYER2, 100, 63, 0, 0 )
  568.  
  569.     PORT_START /* IN1 - Y AXIS */
  570.     PORT_ANALOG( 0xff, 0x80, IPT_TRACKBALL_Y | IPF_PLAYER2, 100, 63, 0, 0 )
  571.  
  572.     PORT_START /* IN1 - BUTTON */
  573.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  574.  
  575.     PORT_START /* IN2 - Active LOW */
  576.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  577.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  578.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
  579.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
  580.  
  581.     PORT_START    /* no fake port here */
  582.     PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
  583. INPUT_PORTS_END
  584.  
  585.  
  586.  
  587.  
  588. static struct GfxLayout charlayout =
  589. {
  590.     8,8,    /* 8*8 characters */
  591.     512,    /* 512 characters */
  592.     4,    /* 4 bits per pixel */
  593.     { 0, 1, 2, 3 },    /* the bitplanes are packed in one nibble */
  594.     { 1*4, 0*4, 3*4, 2*4, 5*4, 4*4, 7*4, 6*4 },
  595.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  596.     32*8    /* every char takes 32 consecutive bytes */
  597. };
  598.  
  599. static struct GfxLayout spritelayout =
  600. {
  601.     16,16,    /* 16*16 sprites */
  602.     512,    /* 512 sprites */
  603.     4,    /* 4 bits per pixel */
  604.     { 0, 1, 2, 3 },    /* the bitplanes are packed in one nibble */
  605.     { 1*4, 0*4, 3*4, 2*4, 5*4, 4*4, 7*4, 6*4,
  606.             8*32+1*4, 8*32+0*4, 8*32+3*4, 8*32+2*4, 8*32+5*4, 8*32+4*4, 8*32+7*4, 8*32+6*4 },
  607.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
  608.             16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 },
  609.     128*8    /* every char takes 32 consecutive bytes */
  610. };
  611.  
  612. static struct GfxLayout tilelayout =
  613. {
  614.     16,8,    /* 16*8 characters */
  615.     1024,    /* 1024 characters */
  616.     4,    /* 4 bits per pixel */
  617.     { 0, 1, 2, 3 },    /* the bitplanes are packed in one nibble */
  618.     { 1*4, 0*4, 3*4, 2*4, 5*4, 4*4, 7*4, 6*4,
  619.         32*8+1*4, 32*8+0*4, 32*8+3*4, 32*8+2*4, 32*8+5*4, 32*8+4*4, 32*8+7*4, 32*8+6*4 },
  620.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  621.     64*8    /* every char takes 64 consecutive bytes */
  622. };
  623.  
  624. static struct GfxDecodeInfo gfxdecodeinfo[] =
  625. {
  626.     { REGION_GFX1, 0, &charlayout,     0, 16 }, /* Colors 0 - 255 */
  627.     { REGION_GFX2, 0, &spritelayout, 256,  8 }, /* Colors 256 - 383 */
  628.     { REGION_GFX3, 0, &tilelayout,   512, 16 }, /* Colors 512 - 767 */
  629.     { -1 } /* end of array */
  630. };
  631.  
  632.  
  633.  
  634. static struct AY8910interface ay8910_interface =
  635. {
  636.     2,    /* 2 chips */
  637.     1536000,     /* ??? */
  638.     { 25, 25 },
  639.     { 0, tehkanwc_portA_r },
  640.     { 0, tehkanwc_portB_r },
  641.     { tehkanwc_portA_w, 0 },
  642.     { tehkanwc_portB_w, 0 }
  643. };
  644.  
  645. static struct MSM5205interface msm5205_interface =
  646. {
  647.     1,                    /* 1 chip             */
  648.     384000,                /* 384KHz             */
  649.     { tehkanwc_adpcm_int },/* interrupt function */
  650.     { MSM5205_S48_4B },    /* 8KHz               */
  651.     { 25 }
  652. };
  653.  
  654. static struct MachineDriver machine_driver_tehkanwc =
  655. {
  656.     /* basic machine hardware */
  657.     {
  658.         {
  659.             CPU_Z80,
  660.             4608000,    /* 18.432000 / 4 */
  661.             readmem,writemem,0,0,
  662.             interrupt,1
  663.         },
  664.         {
  665.             CPU_Z80,
  666.             4608000,    /* 18.432000 / 4 */
  667.             readmem_sub,writemem_sub,0,0,
  668.             interrupt,1
  669.         },
  670.         {
  671.             CPU_Z80,    /* communication is bidirectional, can't mark it as AUDIO_CPU */
  672.             4608000,    /* 18.432000 / 4 */
  673.             readmem_sound,writemem_sound,sound_readport,sound_writeport,
  674.             interrupt,1
  675.         }
  676.     },
  677.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  678.     10,    /* 10 CPU slices per frame - seems enough to keep the CPUs in sync */
  679.     0,
  680.  
  681.     /* video hardware */
  682.     32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 },
  683.     gfxdecodeinfo,
  684.     768, 768,
  685.     0,
  686.  
  687.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  688.     0,
  689.     tehkanwc_vh_start,
  690.     tehkanwc_vh_stop,
  691.     tehkanwc_vh_screenrefresh,
  692.  
  693.     /* sound hardware */
  694.     0,0,0,0,
  695.     {
  696.         {
  697.             SOUND_AY8910,
  698.             &ay8910_interface
  699.         },
  700.         {
  701.             SOUND_MSM5205,
  702.             &msm5205_interface
  703.         }
  704.     }
  705. };
  706.  
  707.  
  708.  
  709. /***************************************************************************
  710.  
  711.   Game driver(s)
  712.  
  713. ***************************************************************************/
  714.  
  715. ROM_START( tehkanwc )
  716.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for code */
  717.     ROM_LOAD( "twc-1.bin",    0x0000, 0x4000, 0x34d6d5ff )
  718.     ROM_LOAD( "twc-2.bin",    0x4000, 0x4000, 0x7017a221 )
  719.     ROM_LOAD( "twc-3.bin",    0x8000, 0x4000, 0x8b662902 )
  720.  
  721.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for code */
  722.     ROM_LOAD( "twc-4.bin",    0x0000, 0x8000, 0x70a9f883 )
  723.  
  724.     ROM_REGION( 0x10000, REGION_CPU3 )    /* 64k for code */
  725.     ROM_LOAD( "twc-6.bin",    0x0000, 0x4000, 0xe3112be2 )
  726.  
  727.     ROM_REGION( 0x04000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  728.     ROM_LOAD( "twc-12.bin",   0x00000, 0x4000, 0xa9e274f8 )    /* fg tiles */
  729.  
  730.     ROM_REGION( 0x10000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  731.     ROM_LOAD( "twc-8.bin",    0x00000, 0x8000, 0x055a5264 )    /* sprites */
  732.     ROM_LOAD( "twc-7.bin",    0x08000, 0x8000, 0x59faebe7 )
  733.  
  734.     ROM_REGION( 0x10000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  735.     ROM_LOAD( "twc-11.bin",   0x00000, 0x8000, 0x669389fc )    /* bg tiles */
  736.     ROM_LOAD( "twc-9.bin",    0x08000, 0x8000, 0x347ef108 )
  737.  
  738.     ROM_REGION( 0x8000, REGION_SOUND1 )    /* ADPCM samples */
  739.     ROM_LOAD( "twc-5.bin",    0x0000, 0x4000, 0x444b5544 )
  740. ROM_END
  741.  
  742. ROM_START( gridiron )
  743.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for code */
  744.     ROM_LOAD( "gfight1.bin",  0x0000, 0x4000, 0x51612741 )
  745.     ROM_LOAD( "gfight2.bin",  0x4000, 0x4000, 0xa678db48 )
  746.     ROM_LOAD( "gfight3.bin",  0x8000, 0x4000, 0x8c227c33 )
  747.  
  748.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for code */
  749.     ROM_LOAD( "gfight4.bin",  0x0000, 0x4000, 0x8821415f )
  750.  
  751.     ROM_REGION( 0x10000, REGION_CPU3 )    /* 64k for code */
  752.     ROM_LOAD( "gfight5.bin",  0x0000, 0x4000, 0x92ca3c07 )
  753.  
  754.     ROM_REGION( 0x04000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  755.     ROM_LOAD( "gfight7.bin",  0x00000, 0x4000, 0x04390cca )    /* fg tiles */
  756.  
  757.     ROM_REGION( 0x10000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  758.     ROM_LOAD( "gfight8.bin",  0x00000, 0x4000, 0x5de6a70f )    /* sprites */
  759.     ROM_LOAD( "gfight9.bin",  0x04000, 0x4000, 0xeac9dc16 )
  760.     ROM_LOAD( "gfight10.bin", 0x08000, 0x4000, 0x61d0690f )
  761.     /* 0c000-0ffff empty */
  762.  
  763.     ROM_REGION( 0x10000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  764.     ROM_LOAD( "gfight11.bin", 0x00000, 0x4000, 0x80b09c03 )    /* bg tiles */
  765.     ROM_LOAD( "gfight12.bin", 0x04000, 0x4000, 0x1b615eae )
  766.     /* 08000-0ffff empty */
  767.  
  768.     ROM_REGION( 0x8000, REGION_SOUND1 )    /* ADPCM samples */
  769.     ROM_LOAD( "gfight6.bin",  0x0000, 0x4000, 0xd05d463d )
  770. ROM_END
  771.  
  772. ROM_START( teedoff )
  773.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for code */
  774.     ROM_LOAD( "to-1.bin",     0x0000, 0x4000, 0xcc2aebc5 )
  775.     ROM_LOAD( "to-2.bin",     0x4000, 0x4000, 0xf7c9f138 )
  776.     ROM_LOAD( "to-3.bin",     0x8000, 0x4000, 0xa0f0a6da )
  777.  
  778.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for code */
  779.     ROM_LOAD( "to-4.bin",     0x0000, 0x8000, 0xe922cbd2 )
  780.  
  781.     ROM_REGION( 0x10000, REGION_CPU3 )    /* 64k for code */
  782.     ROM_LOAD( "to-6.bin",     0x0000, 0x4000, 0xd8dfe1c8 )
  783.  
  784.     ROM_REGION( 0x04000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  785.     ROM_LOAD( "to-12.bin",    0x00000, 0x4000, 0x4f44622c )    /* fg tiles */
  786.  
  787.     ROM_REGION( 0x10000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  788.     ROM_LOAD( "to-8.bin",     0x00000, 0x8000, 0x363bd1ba )    /* sprites */
  789.     ROM_LOAD( "to-7.bin",     0x08000, 0x8000, 0x6583fa5b )
  790.  
  791.     ROM_REGION( 0x10000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  792.     ROM_LOAD( "to-11.bin",    0x00000, 0x8000, 0x1ec00cb5 )    /* bg tiles */
  793.     ROM_LOAD( "to-9.bin",     0x08000, 0x8000, 0xa14347f0 )
  794.  
  795.     ROM_REGION( 0x8000, REGION_SOUND1 )    /* ADPCM samples */
  796.     ROM_LOAD( "to-5.bin",     0x0000, 0x8000, 0xe5e4246b )
  797. ROM_END
  798.  
  799.  
  800.  
  801. GAME( 1985, tehkanwc, 0, tehkanwc, tehkanwc, 0, ROT0,  "Tehkan", "Tehkan World Cup" )
  802. GAME( 1985, gridiron, 0, tehkanwc, gridiron, 0, ROT0,  "Tehkan", "Gridiron Fight" )
  803. GAMEX(1986, teedoff,  0, tehkanwc, teedoff,  0, ROT90, "Tecmo", "Tee'd Off", GAME_NOT_WORKING )
  804.